package com.syqc.net

import com.syqc.comlib.UserConstant
import com.syqc.comlib.entity.AppConfig
import com.syqc.comlib.entity.AppGpsColumn
import com.syqc.comlib.utils.AppContext
import com.syqc.comlib.utils.BuildConfigs
import com.syqc.comlib.utils.GsonUtil
import com.syqc.comlib.utils.Language
import com.syqc.comlib.utils.MLog
import com.syqc.entity.AboutUs
import com.syqc.entity.AccStats
import com.syqc.entity.AdminRegion
import com.syqc.entity.AlarmCar
import com.syqc.entity.AlarmCount
import com.syqc.entity.AlarmDetail
import com.syqc.entity.AlarmMedia
import com.syqc.entity.AlarmNote
import com.syqc.entity.AlarmType
import com.syqc.entity.AllData
import com.syqc.entity.ArrearsInfo
import com.syqc.entity.ArrearsNotice
import com.syqc.entity.CarAround
import com.syqc.entity.CarInfo
import com.syqc.entity.CarLick
import com.syqc.entity.CarSign
import com.syqc.entity.CarState
import com.syqc.entity.CarTmn
import com.syqc.entity.CardInfo
import com.syqc.entity.ChangeCarTeam
import com.syqc.entity.CheckInfo
import com.syqc.entity.CmdInfo
import com.syqc.entity.CmdLog
import com.syqc.entity.CmdNote
import com.syqc.entity.CmdReply
import com.syqc.entity.ContactUs
import com.syqc.entity.DayMile
import com.syqc.entity.DeviceExc
import com.syqc.entity.DeviceInfo
import com.syqc.entity.Dictionary
import com.syqc.entity.DriverInfo
import com.syqc.entity.DriverSign
import com.syqc.entity.Expire
import com.syqc.entity.Fees
import com.syqc.entity.FlowInfo
import com.syqc.entity.FwdRev
import com.syqc.entity.GpsDetail
import com.syqc.entity.HBaseBean
import com.syqc.entity.HistoryAlarm
import com.syqc.entity.HistoryLine
import com.syqc.entity.HistoryLogin
import com.syqc.entity.HomeData
import com.syqc.entity.HourPoint
import com.syqc.entity.IdentityImg
import com.syqc.entity.IdentityInfo
import com.syqc.entity.InsureInfo
import com.syqc.entity.Legend
import com.syqc.entity.LocationInfo
import com.syqc.entity.LocationPoi
import com.syqc.entity.LogTypeInfo
import com.syqc.entity.LoginEntity
import com.syqc.entity.LoginPre
import com.syqc.entity.OfflineInfo
import com.syqc.entity.OfflineState
import com.syqc.entity.OilCard
import com.syqc.entity.OilDay
import com.syqc.entity.OilPoint
import com.syqc.entity.PhotoInfo
import com.syqc.entity.PoiInfo
import com.syqc.entity.PoiStati
import com.syqc.entity.PsiRpt
import com.syqc.entity.QrCode
import com.syqc.entity.RegionCar
import com.syqc.entity.RegionInfo
import com.syqc.entity.RegionState
import com.syqc.entity.RegionStats
import com.syqc.entity.RemindInfo
import com.syqc.entity.RepairInfo
import com.syqc.entity.RunCar
import com.syqc.entity.RunCarState
import com.syqc.entity.SelfInfo
import com.syqc.entity.SensorCfg
import com.syqc.entity.SensorInfo
import com.syqc.entity.SgnRemind
import com.syqc.entity.SmsCmdInfo
import com.syqc.entity.StopStats
import com.syqc.entity.SystemMessage
import com.syqc.entity.TeamCars
import com.syqc.entity.TeamInfo
import com.syqc.entity.TeamsCars
import com.syqc.entity.TempDay
import com.syqc.entity.TextCar
import com.syqc.entity.TmnManager
import com.syqc.entity.UpdateEntity
import com.syqc.entity.Version
import com.syqc.entity.VersionInfo
import com.syqc.monitor.R
import com.syqc.utils.UrlUtil
import io.reactivex.rxjava3.core.Single
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.MultipartBody
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody

/** @Author pc_hfjs @Date 2022/1/19 15:52 @Desc */
class NetRepository {
    //网络请求超时时间短 5秒
    private val sortTime = 5
    private var api = Net.getService(ServiceApi::class.java)

    private var noParamApi = Net.getServiceNoParams(ServiceApi::class.java)

    //改变链接
    fun changeHost() {
        api = Net.getService(ServiceApi::class.java)
        noParamApi = Net.getServiceNoParams(ServiceApi::class.java)
    }

    /** 获取统计数据 */
    fun getDayStats(
        type: Int,
        typeId: String,
        carId: String,
        date: String
    ): Single<ArrayList<OilDay>> {
        return api.getDayStats(type, typeId, carId, date)
            .compose(Net.applySingleSchedulers()).map {
                GsonUtil.formArrayList(it.result.toString(), OilDay::class.java)
            }
    }

    /** 获取统计数据 */
    fun getTempStats(
        type: Int,
        typeId: String,
        carId: String,
        date: String
    ): Single<ArrayList<TempDay>> {
        return api.getDayStats(type, typeId, carId, date)
            .compose(Net.applySingleSchedulers()).map {
                MLog.e("------------------------${it.result}")
                GsonUtil.formArrayList(it.result.toString(), TempDay::class.java)
            }
    }

    /**
     * 获取数据详情
     *
     * @param carId
     * @param day
     * @param cfg
     * @return
     */
    fun getNodes(carId: String, day: String, cfg: String): Single<ArrayList<OilPoint>> {
        return api.getNodes(carId, day, cfg)
            .compose(Net.applySingleSchedulers()).map {
                GsonUtil.formArrayList(it.result.toString(), OilPoint::class.java)
            }
    }

    /**
     * 获取数据详情
     *
     * @param carId
     * @param day
     * @param cfg
     * @return
     */
    fun getNodesMap(carId: String, day: String, cfg: String): Single<ArrayList<String>> {
        return api.getNodes(carId, day, cfg)
            .compose(Net.applySingleSchedulers()).map {
                GsonUtil.formArrayStr(it.result.toString())
            }
    }

    suspend fun getNodesDay(carId: String, day: String, cfg: String): Single<ArrayList<String>> {
        return withContext(Dispatchers.IO) {
            api.getNodes(carId, day, cfg)
                .compose(Net.applySingleSchedulers()).map {
                    GsonUtil.formArrayStr(it.result.toString())
                }
        }
    }

    /** 获取定位简易 */
    fun getGpsR(
        teamId: String,
        carIds: String,
        simple: Boolean,
        filter: Boolean
    ): Single<ArrayList<GpsDetail>> {
        return api.getGpsR(teamId, carIds, simple, filter)
            .compose(Net.applySingleSchedulers()).map {
                GsonUtil.formArrayList(it.result.toString(), GpsDetail::class.java)
            }
    }

    /** 获取定位详情信息 */
    fun getGpsRInfo(
        teamId: String,
        carIds: String,
        simple: Boolean = false,
        filter: Boolean = true
    ): Single<ArrayList<GpsDetail>> {
        return api.getGpsR(teamId, carIds, simple, filter)
            .compose(Net.applySingleSchedulers()).map {
                GsonUtil.formArrayList(it.result.toString(), GpsDetail::class.java)
            }
    }

    /** 获取定位详情信息 */
    fun getCareInfo(
        teamId: String,
        carIds: String,
        simple: Boolean = false,
        filter: Boolean = false
    ): Single<ArrayList<GpsDetail>> {
        return api.getGpsR(teamId, carIds, simple, filter)
            .compose(Net.applySingleSchedulers()).map {
                GsonUtil.formArrayList(it.result.toString(), GpsDetail::class.java)
            }
    }

    /** 历史轨迹停车报警地点 */
    fun getAllHisGps(
        carId: String,
        startTime: String,
        endTime: String,
        maxSpeed: String,
        stopLong: String,
        filterInvalid: Boolean,
        filterAppend: Boolean,
        filterStop: Boolean,
    ): Single<HistoryLine> =
        api.getAllHisGps(
            carId, startTime, endTime, maxSpeed, stopLong, filterInvalid,
            filterAppend, filterStop
        ).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formObject<HistoryLine>(it.result.toString())
        }

    /** 获取车辆信号线或提醒 */
    fun getCarSgnRemind(carId: String, type: String): Single<SgnRemind> =
        api.getCarSgnRemind(carId, type).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formObject<SgnRemind>(it.result.toString())
        }


    //查询版本信息
    fun getVersion(): Single<Version> =
        Net.getServiceParams(
            ServiceApi::class.java,
            UrlUtil.newBase(BuildConfigs.IP, BuildConfigs.PORT)
        ).getAppVer("android", "android")
            .compose(Net.applySingleSchedulers()).map {
                GsonUtil.formObject<Version>(it.result.toString())
            }

    /**
     * Get version list 获取版本列表
     *
     * @param url
     * @return
     */
    fun getVersionList(url: String): Single<List<String>> =
        noParamApi.getVersionList(url).compose(Net.applyNoMapSingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), String::class.java)
        }

    /**
     * Get version info 获取版本信息
     *
     * @param url
     * @return
     */
    fun getVersionInfo(url: String): Single<VersionInfo> =
        noParamApi.getVersionInfo(url).compose(Net.applyNoMapSingleSchedulers())

    /**
     * 获取新版本
     *
     * @param url
     * @return
     */
    fun getNewVersion(url: String): Single<UpdateEntity> =
        Net.getServiceParams(
            ServiceApi::class.java,
            "https://31gps.net/"
        ).getUpdate(url).compose(Net.applyNoMapSingleSchedulers())

    /** 登录 */
    fun login(
        userId: String,
        pwd: String,
        loginType: String,
        plateColor: String = "",
        sms: Boolean = false,
        smsCode: String = "",
        lat: Double = 0.0,
        lng: Double = 0.0
    ): Single<LoginEntity> =
        api.login(
            userId, pwd, loginType, plateColor,
            Language.getCurrentLanguage(), BuildConfigs.VERSION_NAME, sms, smsCode,
            lat, lng, "android"
        ).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formObject<LoginEntity>(it.result.toString())
        }

    /** 登出 */
    fun logout(): Single<HBaseBean> =
        api.logout().compose(Net.applySingleSchedulers())

    /**
     * Logout no interceptor
     *   退出登录，不使用拦截器
     * @return
     */
    fun logoutNoInterceptor(): Single<HBaseBean> =
        api.logout().compose(Net.applyNoMapSingleSchedulers())

    /** 字典 */
    fun getDictionary(types: String): Single<Dictionary> =
        api.getDictionary(types, false, Language.getCurrentLanguage())
            .compose(Net.applySingleSchedulers()).map {
                GsonUtil.formObject<Dictionary>(it.result.toString())
            }

    /** 字典 */
    fun getUserExt(): Single<String> =
        api.getDictionary("USER_EXT", false, Language.getCurrentLanguage())
            .compose(Net.applySingleSchedulers()).map {
                it.result.toString()
            }

    /** 链接获取车辆详情 */
    fun getCarInfoQr(url: String): Single<QrCode> =
        noParamApi.getQrCarInfo(url).compose(Net.applySingleSchedulers())

    /** 获取车辆详情 */
    fun getCarInfo(carId: String): Single<CarInfo> =
        api.getCarInfo(carId).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formObject<CarInfo>(it.result.toString())
        }

    /** 获取车辆详情 */
    fun getVerify(carId: String): Single<String> =
        api.getVerify(carId).compose(Net.applySingleSchedulers()).map {
            it.result.toString()
        }

    /** 查询消息公告 */
    fun getMessage(): Single<ArrayList<SystemMessage>> =
        api.getSysMsg().compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), SystemMessage::class.java)
        }

    /**
     * ***************************************车队车辆相关*****************************************************
     */
    /** 查询车队列表 */
    fun getTeams(teamId: String = ""): Single<ArrayList<TeamInfo>> =
        api.getTeamList(teamId).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), TeamInfo::class.java)
        }

    /** 车队车辆逐级查询 */
    fun getTeamCars(teamId: String = "0", video: Boolean): Single<TeamsCars> =
        api.getTeamCarList(teamId, video).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formObject<TeamsCars>(it.result.toString())
        }

    /** 车队车辆查询 */
    fun getTeamsAndCars(isQueryCar: Boolean = true): Single<TeamCars> =
        api.getTeamsAndCars(isQueryCar).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formObject<TeamCars>(it.result.toString())
        }

    /** 模糊查询车辆 */
    fun getSearchCar(
        key: String = "",
        type: String = "1",
        video: Boolean
    ): Single<ArrayList<CarLick>> =
        api.getCarsLike(key, type, video).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), CarLick::class.java)
        }

    /** 图例 */
    fun getLegend(carId: String): Single<ArrayList<Legend>> =
        api.legend(carId).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), Legend::class.java)
        }

    /**
     * ****************************** 报表相关
     * *****************************************************
     */
    /** 查询报警类型 */
    fun getAlarmType(isAdas: Boolean): Single<ArrayList<AlarmType>> =
        api.getAlarmType(if (isAdas) 2 else 1).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), AlarmType::class.java)
        }

    /** 查询报警历史 */
    fun getHistoryAlarm(
        carId: String,
        startTime: String,
        endTime: String,
        typeIds: String,
        speed: String = "0",
        duration: String = "00:00:00"
    ): Single<HistoryAlarm> {

        MLog.e("fsdhfksdfhsdfjsdfh     $duration")
        return api.getHistoryAlarms(carId, startTime, endTime, typeIds, speed, duration)
            .compose(Net.applySingleSchedulers()).map {
                GsonUtil.formObject<HistoryAlarm>(it.result.toString())
            }
    }

    /** 当前报警统计 */
    fun getAlarmCount(): Single<ArrayList<AlarmCount>> =
        api.getAlarmCount().compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), AlarmCount::class.java)
        }

    /** 获取车辆报警
     */
    fun getCarAlarms(): Single<ArrayList<AlarmCar>> =
        api.getCarAlarms().compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), AlarmCar::class.java)
        }

    /** 查询报警详情 */
    fun getAlarmDetail(alarmType: String): Single<ArrayList<AlarmDetail>> =
        api.getAlarmDetail(alarmType).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), AlarmDetail::class.java)
        }

    /** 报警数据 */
    fun getAlarmDetailCar(carId: String): Single<ArrayList<AlarmDetail>> =
        api.getAlarmDetailCar(carId).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), AlarmDetail::class.java)
        }

    /** 查询主动安全的多媒体数据 */
    fun getAlarmMedia(
        carId: String,
        time: String,
        alarmType: String
    ): Single<ArrayList<AlarmMedia>> =
        api.getAlarmMedia(carId, time, alarmType).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), AlarmMedia::class.java)
        }

    //订阅报警
    fun setAlarmType(alarmIds: String): Single<HBaseBean> =
        api.setAlarms(alarmIds).compose(Net.applySingleSchedulers())

    /** 根据时间查日里程 */
    fun getDayMile(
        carId: String,
        startTime: String,
        endTime: String,
        isSum: Boolean = false
    ): Single<DayMile> =
        api.queryMile(carId, startTime, endTime, isSum).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formObject<DayMile>(it.result.toString())
        }
    /**
     * ************************************
     * *****************************************************
     */
    /** 查询历史照片 */
    fun getHistoryPhotos(
        carId: String,
        startTime: String,
        endTime: String
    ): Single<ArrayList<PhotoInfo>> =
        api.queryPhoto(carId, startTime, endTime).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), PhotoInfo::class.java)
        }

    /** 费用分析 */
    fun getFeeDetail(
        carId: String,
        startTime: String,
        endTime: String
    ): Single<Fees> =
        api.feeStats(carId, startTime, endTime).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formObject<Fees>(it.result.toString())
        }

    /** 费用各项详情 */
    fun getFeeInfo(
        carId: String,
        feeType: String,
        startTime: String,
        endTime: String,
        driverName: String = ""
    ): Single<HBaseBean> =
        api.queryFeeInfo(carId, feeType, startTime, endTime, driverName)
            .compose(Net.applySingleSchedulers())

    /** 整体数据 */
    fun getAllData(): Single<AllData> =
        api.overallData().compose(Net.applySingleSchedulers()).map {
            GsonUtil.formObject<AllData>(it.result.toString())
        }

    /** 停车统计 */
    fun getStopData(
        carId: String,
        startTime: String,
        endTime: String,
        duration: String,
        acc: Boolean,
    ): Single<StopStats> =
        api.stopStats(carId, startTime, endTime, duration, acc)
            .compose(Net.applySingleSchedulers()).map {
                GsonUtil.formObject<StopStats>(it.result.toString())
            }

    /** 获取模拟量设置信息 */
    fun getMnConfig(carId: String, analogCode: String): Single<ArrayList<SensorCfg>> =
        api.sensorCfg(carId, analogCode).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), SensorCfg::class.java)
        }


    /** 模拟量统计 */
    fun getAnalogStats(
        carId: String,
        startTime: String,
        endTime: String,
        analogCode: String,
        mnIndex: String
    ): Single<ArrayList<SensorInfo>> =
        api.sensorStats(carId, startTime, endTime, analogCode, mnIndex)
            .compose(Net.applySingleSchedulers()).map {
                GsonUtil.formArrayList(it.result.toString(), SensorInfo::class.java)
            }

    /** 提醒查询 */
    fun getRemindData(teamId: String, type: String): Single<ArrayList<RemindInfo>> =
        api.queryReminds(teamId, type).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), RemindInfo::class.java)
        }

    /** 整点位置 */
    fun getPointsData(carId: String, date: String): Single<ArrayList<HourPoint>> =
        api.queryHourPoint(carId, date).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), HourPoint::class.java)
        }

    /** ACC状态 */
    fun getAccStatsData(carId: String, startTime: String, endTime: String): Single<AccStats> =
        api.accStats(carId, startTime, endTime).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formObject<AccStats>(it.result.toString())
        }

    /** 车辆登退签 */
    fun getCarSignInOut(carId: String, startTime: String, endTime: String): Single<CarSign> =
        api.querySignCar(carId, startTime, endTime)
            .compose(Net.applySingleSchedulers()).map {
                GsonUtil.formObject<CarSign>(it.result.toString())
            }

    /** 司机登退签 */
    fun getDriverSignInOut(
        driverId: String,
        startTime: String,
        endTime: String
    ): Single<DriverSign> =
        api.querySignDriver(driverId, startTime, endTime)
            .compose(Net.applySingleSchedulers()).map {
                GsonUtil.formObject<DriverSign>(it.result.toString())
            }

    /** 获取司机信息 */
    fun getDriversData(): Single<ArrayList<DriverInfo>> =
        api.queryDriver().compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), DriverInfo::class.java)
        }

    /** 流量统计 */
    fun getFlowStatsData(
        carId: String,
        startTime: String,
        endTime: String
    ): Single<ArrayList<FlowInfo>> =
        api.flowStats(carId, startTime, endTime).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), FlowInfo::class.java)
        }

    /** 视频流量统计 */
    fun getVideosStats(
        carId: String,
        startTime: String,
        endTime: String
    ): Single<ArrayList<FlowInfo>> =
        api.videoStats(carId, startTime, endTime).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), FlowInfo::class.java)
        }

    /** 查岗历史 */
    fun getCheckHistory(
        startTime: String,
        endTime: String
    ): Single<ArrayList<CheckInfo>> =
        api.queryCheck(startTime, endTime).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), CheckInfo::class.java)
        }

    /** 保险查询 */
    fun getInsureData(
        carId: String,
        startTime: String,
        endTime: String
    ): Single<ArrayList<InsureInfo>> =
        api.getInsurance(carId, startTime, endTime).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), InsureInfo::class.java)
        }

    /** 证件查询 */
    fun getCardData(
        carId: String,
        startTime: String,
        endTime: String,
        type: String
    ): Single<ArrayList<CardInfo>> = api.getCertificate(carId, startTime, endTime, type)
        .compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), CardInfo::class.java)
        }

    /** 查询日志相关 */
    fun getLogOpera(
        action: String,
        carId: String,
        cmdId: String,
        typeId: String,
        startTime: String,
        endTime: String,
        opera: String
    ): Single<ArrayList<CmdLog>> =
        api.queryLog(action, startTime, endTime, typeId, opera, cmdId, carId)
            .compose(Net.applySingleSchedulers()).map {
                GsonUtil.formArrayList(it.result.toString(), CmdLog::class.java)
            }

    /** 查询指令 */
    fun getCmdData(): Single<ArrayList<CmdInfo>> =
        api.cmdList().compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), CmdInfo::class.java)
        }


    /** 获取指令类型 */
    fun getLogData(): Single<ArrayList<LogTypeInfo>> =
        api.logType().compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), LogTypeInfo::class.java)
        }

    /** 区域统计 */
    fun getRegionCars(regionId: String): Single<ArrayList<RegionStats>> =
        api.getRegionCars(regionId).compose(Net.applySingleSchedulers()).map {
            MLog.e("区域统计========$it")
            GsonUtil.formArrayList(it.result.toString(), RegionStats::class.java)
        }

    /** 标注点统计 */
    fun getPoiStati(regionId: String): Single<ArrayList<PoiStati>> =
        api.getMapPoiAndCars(regionId).compose(Net.applySingleSchedulers()).map {
            MLog.e("标注点========$it")
            GsonUtil.formArrayList(it.result.toString(), PoiStati::class.java)
        }

    /** 获取权限下所有区域(不含经纬度) 0-目录 1-区域 */
    fun getRegions(type: String = "1", flag: String = "0"): Single<ArrayList<RegionInfo>> =
        api.getRegions(type, flag).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), RegionInfo::class.java)
        }

    /** 获取权限下所有标注(不含经纬度) 0-目录 1-区域 */
    fun getMapPoi(type: String = "1", flag: String = "0"): Single<ArrayList<PoiInfo>> =
        api.getMapPoi(type, flag).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), PoiInfo::class.java)
        }


    /** 区域查车 */
    fun queryRegion(
        carId: String,
        startTime: String,
        endTime: String,
        regions: String
    ): Single<RegionCar> =
        api.getCarRegions(carId, startTime, endTime, regions)
            .compose(Net.applySingleSchedulers()).map {
                GsonUtil.formObject<RegionCar>(it.result.toString())
            }

    /** 离线统计 */
    fun getOfflineData(
        objType: String,
        objIds: String,
        queryType: String,
        offLineType: String,
        offLineDays: String
    ): Single<ArrayList<OfflineInfo>> =
        api.offlineStats(objType, objIds, queryType, offLineType, offLineDays)
            .compose(Net.applySingleSchedulers()).map {
                GsonUtil.formArrayList(it.result.toString(), OfflineInfo::class.java)
            }

    /** 欠费统计信息 （运营状况） */
    fun getOperationData(teamId: String, days: Int): Single<ArrayList<ArrearsInfo>> =
        api.getArrearsInfo(teamId, days).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), ArrearsInfo::class.java)
        }

    //添加费用
    fun updateImgFee(
        feeType: String,
        entity: String,
        files: List<MultipartBody.Part?>?,
        fields: String = "[]",
        action: String = "add"
    ): Single<HBaseBean> =
        noParamApi.saveFee(UserConstant.sessionId, feeType, action, entity, fields, files)
            .compose(Net.applySingleSchedulers())

    //添加特殊加油费用
    fun updateOilFee(
        carId: String,
        date: String,
        fields: String,
        files: List<MultipartBody.Part?>?
    ): Single<HBaseBean> =
        noParamApi.saveOilFee(UserConstant.sessionId, carId, date, fields, files)
            .compose(Net.applySingleSchedulers())

    private fun getResponseBody(value: String): RequestBody? {
        return value.toRequestBody("text/plain".toMediaTypeOrNull())
    }

    //新增车辆
    fun addCar3(
        plate: String, plateColor: String, simCard: String, tmnNo: String,
        tmnKey: String, teamId: String, keyType: String,
        channelCount: String, owner: String, ownerPhone: String, des: String,
        files: List<MultipartBody.Part?>?
    ): Single<HBaseBean> =
        noParamApi.addCar3(
            UserConstant.sessionId, plate, plateColor, simCard,
            tmnNo, tmnKey, teamId, keyType, channelCount, owner, ownerPhone, des, "", files
        )
            .compose(Net.applySingleSchedulers())

    //新增车辆
    fun addNewCar(
        plate: String,
        plateColor: String,
        simCard: String,
        tmnNo: String,
        tmnKey: String,
        teamId: String,
        keyType: String,
        channelCount: String,
        owner: String,
        ownerPhone: String,
        des: String,
        logicalChannel: String?,
        carName: String?,
        files: List<MultipartBody.Part?>?
    ): Single<HBaseBean> =
        noParamApi.addNewCar(
            UserConstant.sessionId,
            plate,
            plateColor,
            simCard,
            tmnNo,
            tmnKey,
            teamId,
            keyType,
            channelCount,
            owner,
            ownerPhone,
            des,
            logicalChannel,
            carName,
            "",
            files,
        )
            .compose(Net.applySingleSchedulers())

    //新增车辆
    fun addNewCar2(
        plate: String, plateColor: String, teamId: String, channelCount: String,
        owner: String, ownerPhone: String, des: String, tmnId: String, logicalChannel: String?,
        carName: String?,
        files: List<MultipartBody.Part?>?
    ): Single<HBaseBean> =
        noParamApi.addNewCar2(
            UserConstant.sessionId, plate, plateColor, teamId,
            channelCount, owner, ownerPhone, tmnId, des, logicalChannel, carName, "", files
        ).compose(Net.applySingleSchedulers())


    //指令下发
    fun sendCmd(
        userId: String,
        carId: String,
        cmdId: String,
        cmd: String,
        params: String
    ): Single<CmdReply> =
        api.sendCmd(userId, carId, cmdId, cmd, params)
            .compose(Net.applySingleSchedulers()).map {
                GsonUtil.formObject<CmdReply>(it.result.toString())
            }

    /** 获取短信指令 */
    fun getSMSCmd(): Single<ArrayList<SmsCmdInfo>> =
        api.smsCmd().compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), SmsCmdInfo::class.java)
        }

    /** 获取维修列表 */
    fun getRepairs(): Single<ArrayList<RepairInfo>> =
        api.getRepairList().compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), RepairInfo::class.java)
        }

    //维修回复提交
    fun updateRepair(
        modifyId: String,
        desc: String,
        files: List<MultipartBody.Part?>?
    ): Single<HBaseBean> =
        noParamApi.replyRepair(UserConstant.sessionId, modifyId, desc, files)
            .compose(Net.applySingleSchedulers())

    //维修申报
    fun submitRepair(
        carId: String,
        tickName: String,
        tickPhone: String,
        tickDesc: String,
        files: List<MultipartBody.Part?>?
    ): Single<HBaseBean> =
        noParamApi.addRepair(
            UserConstant.sessionId,
            carId,
            tickName,
            tickPhone,
            tickDesc,
            "",
            files
        )
            .compose(Net.applySingleSchedulers())

    /**
     * ************************************** Menu 菜单
     * ***************************************************
     */
    /** 登录历史 */
    fun getLoginHistory(): Single<ArrayList<HistoryLogin>> =
        api.loginHistory().compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), HistoryLogin::class.java)
        }

    /** 关于我们 */
    fun aboutUs(): Single<AboutUs> =
        api.aboutUs().compose(Net.applySingleSchedulers()).map {
            GsonUtil.formObject<AboutUs>(it.result.toString())
        }

    /** 关于我们 */
    fun getSelf(): Single<SelfInfo> =
        api.getSelf().compose(Net.applySingleSchedulers()).map {
            GsonUtil.formObject<SelfInfo>(it.result.toString())
        }

    /** 修改密码 */
    fun upPwd(newPwd: String, pwdConvert: Boolean): Single<HBaseBean> =
        api.uptPwd(newPwd, pwdConvert).compose(Net.applySingleSchedulers())

    /** 获取车辆相关照片 */
    fun getPic(carId: String, type: String): Single<ArrayList<String>> =
        api.carPhoto(carId, type).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), String::class.java)
        }

    /** 更新接口 */
    fun getUpdateInfo(url: String): Single<UpdateEntity> =
        noParamApi.getUpdate(url).compose(Net.applySingleSchedulers())

    /** 欠费通知 */
    fun getArrearsInfo(): Single<ArrearsNotice> =
        api.arrearsNotice().compose(Net.applySingleSchedulers()).map {
            GsonUtil.formObject<ArrearsNotice>(it.result.toString())
        }

    /** 单车欠费通知 */
    fun getArrearsInfo(carId: String): Single<Expire> =
        api.arrearsNotice(carId).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formObject<Expire>(it.result.toString())
        }


    /** 车辆修改 */
    fun modifyCar(
        oldCarId: String,
        plate: String,
        carName: String,
        plateColor: String,
        teamId: String,
        channelCount: String,
        deletePicJson: String?,
        owner: String?,
        ownerPhone: String?,
        des: String?,
        logicalChannel: String?,
        addPicFiles: List<MultipartBody.Part?>?
    ): Single<HBaseBean> =
        noParamApi.modifyCar(
            UserConstant.sessionId,
            oldCarId,
            plate,
            carName,
            plateColor,
            teamId,
            channelCount,
            deletePicJson,
            owner,
            ownerPhone,
            "",
            des,
            logicalChannel,
            addPicFiles
        )
            .compose(Net.applySingleSchedulers())

    /** 车辆修改 */
    fun updateCar(
        oldCarId: String,
        plate: String,
        carName: String,
        plateColor: String,
        teamId: String,
        channelCount: String,
        deletePicJson: String?,
        owner: String?,
        ownerPhone: String?,
        tmnId: String?,
        des: String?,
        logicalChannel: String?,
        addPicFiles: List<MultipartBody.Part?>?
    ): Single<HBaseBean> =
        noParamApi.modifyCar(
            UserConstant.sessionId,
            oldCarId, plate, carName, plateColor, teamId, channelCount,
            deletePicJson, owner, ownerPhone, tmnId, des, logicalChannel, addPicFiles
        ).compose(Net.applySingleSchedulers())


    /** 获取常用文本信息 */
    fun getCmdNote(): Single<CmdNote> =
        api.cmdNote().compose(Net.applySingleSchedulers()).map {
            GsonUtil.formObject<CmdNote>(it.result.toString())
        }

    /** 获取报警处理常用文本信息 */
    fun getAlarmNote(): Single<AlarmNote> =
        api.getAlarmNote().compose(Net.applySingleSchedulers()).map {
            GsonUtil.formObject<AlarmNote>(it.result.toString().replace(" ", ""))
        }


    /** 验证一下 */
    fun getDictionaryTest(url: String): Single<Dictionary> =
        Net.getService(ServiceApi::class.java, sortTime).getDictionary(url)
            .compose(Net.applySingleSchedulers()).map {
                MLog.e("*********************$it")
                GsonUtil.formObject<Dictionary>(it.result.toString())
            }

    fun getDictionaryTestHost(types: String): Single<Dictionary> =
        Net.getService(ServiceApi::class.java, sortTime)
            .getDictionary(types, false, Language.getCurrentLanguage())
            .compose(Net.applySingleSchedulers()).map {
                MLog.e("*********************$it")
                GsonUtil.formObject<Dictionary>(it.result.toString())
            }

    /** 手机登录前状态接口 */
    fun getLoginPre(carId: String, loginType: String, plateColor: String): Single<LoginPre> =
        Net.getService(ServiceApi::class.java, sortTime)
            .loginPre(carId, loginType, plateColor, Language.getCurrentLanguage())
            .compose(Net.applySingleSchedulers()).map {
                MLog.e("*********************$it")
                GsonUtil.formObject<LoginPre>(it.result.toString())
            }

    /** 手机登录发送验证码 */
    fun sendSms(userId: String, loginType: String, plateColor: String): Single<HBaseBean> =
        api.sendSms(userId, loginType, plateColor, Language.getCurrentLanguage())
            .compose(Net.applySingleSchedulers())

    /** 获取设备异常 */
    fun getDeviceException(): Single<ArrayList<DeviceExc>> =
        api.deviceExc("1", "").compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), DeviceExc::class.java)
        }

    /** 获取设备异常详情 */
    fun getDeviceInfo(type: String, name: String): Single<ArrayList<DeviceInfo>> =
        api.deviceExc(type, name).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), DeviceInfo::class.java)
        }

    /** 联系我们 */
    fun getCmpLink(): Single<ArrayList<ContactUs>> =
        api.contactUs().compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), ContactUs::class.java)
        }

    /** 车辆周边 */
    fun getCarAround(carId: String, radius: String): Single<ArrayList<CarAround>> =
        api.carAround(carId, radius).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), CarAround::class.java)
        }

    /**
     * ****************************** 视频
     * **************************************************
     */
    //实时视频  历史视频

    fun getVideoState(url: String): Single<String> {
        return Net.getServiceNoParams(ServiceApi::class.java).getVideoState(url)
            .compose(Net.applyNoMapSingleSchedulers())
    }

    fun getVideo(url: String): Single<String> {
        return Net.getServiceNoParams(ServiceApi::class.java).getVideo(url)
            .compose(Net.applyNoMapSingleSchedulers())
    }


    /**
     * ****************************** 个推推送
     * *********************************************
     */
    /** 推送开关接口 */
    fun pushAlarm(isPush: Boolean, clientId: String): Single<HBaseBean> =
        api.push(isPush, clientId).compose(Net.applySingleSchedulers())

    /**
     * ****************************** 微信分享
     * *********************************************
     */
    /** 微信分享实时定位 */
    fun shareLocation(carId: String): Single<HBaseBean> =
        api.shareLocation(carId, "1").compose(Net.applySingleSchedulers())

    /** 微信分享历史轨迹 */
    fun shareLine(
        carId: String, stime: String, etime: String,
        filter0: String, filterInvalid: String, filterAppend: String
    ): Single<HBaseBean> =
        api.shareLine(carId, "h1", stime, etime, filter0, filterInvalid, filterAppend)
            .compose(Net.applySingleSchedulers())

    /** 获取权限下所有标注 */
    fun getAllPoi(): Single<ArrayList<LocationPoi>> =
        api.getPoiS().compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), LocationPoi::class.java)
        }

    /** 通过地址查端口 */
    fun getPortByAddr(urlHost: String, addr: String, isHttps: Boolean): Single<ArrayList<String>> =
        noParamApi.getPortByAddr("http://$urlHost:9999/api/plat/getPortByAddress?address=$addr&language=${Language.getCurrentLanguage()}&protol=${if (isHttps) "https" else "http"}")
            .compose(Net.applySingleSchedulers()).map {
                GsonUtil.formArrayList(it.result.toString(), String::class.java)
            }

    /** 获取用户配置 */
    fun getAppConfig(): Single<AppConfig> =
        api.getAppCfg().compose(Net.applySingleSchedulers()).map {
            GsonUtil.formObject<AppConfig>(it.result.toString())
        }

    /** 获取用户配置 */
    fun getCarConfig(carId: String): Single<AppConfig> =
        api.getCfgByCar(carId).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formObject<AppConfig>(it.result.toString())
        }

    /** 保存用户设置 */
    fun saveAppConfig(key: String, data: String): Single<HBaseBean> =
        api.saveAppCfg(key, data).compose(Net.applySingleSchedulers())

    /** 保存用户设置 */
    fun saveCarSetCfg(carids: String, data: String): Single<HBaseBean> =
        api.saveCarSetCfg(carids, data).compose(Net.applySingleSchedulers())

    /** 获取单车配置 */
    fun getCarCfg(carId: String): Single<ArrayList<AppGpsColumn>> =
        api.getCarCfg(carId).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), AppGpsColumn::class.java)
        }

    /** 保存单车设置 */
    fun saveCarCfg(carids: String, data: String): Single<HBaseBean> =
        api.saveCarCfg(carids, data).compose(Net.applySingleSchedulers())

    /**
     * 检测版本
     *
     * @param url
     */
    fun checkVersion(url: String) = api.checkVersion(url)

    /**
     * 检测账号密码是否正确
     *
     * @param userId
     * @param loginType
     * @param password
     * @param plateColor
     * @param loginLang
     */
    fun checkLogin(
        userId: String,
        loginType: String,
        password: String,
        plateColor: String,
        loginLang: String,
        sms: String,
        smsCode: String,
        version: String,
    ) = Net.getService(ServiceApi::class.java, sortTime)
        .checkLogin(userId, loginType, password, plateColor, loginLang, sms, smsCode, version)

    /**
     * 获取联系方式
     *
     * @param url
     */
    fun getPhone(url: String) = Net.getService(ServiceApi::class.java, sortTime).getPhone(url)

    /** 行车统计分析 */
    fun queryRun(
        carId: String,
        startTime: String,
        endTime: String,
        speedMin: String,
        speedMax: String,
        duration: String,
        chinas: String,
        regions: String
    ): Single<RunCar> =
        api.queryRun(carId, startTime, endTime, speedMin, speedMax, duration, chinas, regions)
            .compose(Net.applySingleSchedulers()).map {
                GsonUtil.formObject<RunCar>(it.result.toString())
            }

    /** 行驶状态分析 */
    fun queryState(
        carId: String,
        startTime: String,
        endTime: String
    ): Single<ArrayList<RunCarState>> =
        api.queryState(carId, startTime, endTime)
            .compose(Net.applySingleSchedulers()).map {
                GsonUtil.formArrayList(it.result.toString(), RunCarState::class.java)
            }

    /** 获取权限下油卡 */
    fun getOilCard(): Single<ArrayList<OilCard>> =
        api.getOilCard().compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), OilCard::class.java)
        }

    /** 胎压报表 */
    fun getPsiRpt(
        carId: String,
        startTime: String,
        endTime: String
    ): Single<ArrayList<PsiRpt>> =
        api.getPsiRpt(carId, startTime, endTime)
            .compose(Net.applySingleSchedulers()).map {
                GsonUtil.formArrayList(it.result.toString(), PsiRpt::class.java)
            }

    /** 查询全国⾏政区域编码 */
    fun getAreaCode(): Single<ArrayList<AdminRegion>> =
        api.getAllAreaCode()
            .compose(Net.applySingleSchedulers()).map {
                GsonUtil.formArrayList(it.result.toString(), AdminRegion::class.java)
            }

    /** 心跳链接接口 */
    fun clientHeart(): Single<HBaseBean> =
        api.clientHeart().compose(Net.applySingleSchedulers())

    /** 延迟心跳链接接口 */
    fun delayHeart(): Single<HBaseBean> =
        api.delayHeart().compose(Net.applySingleSchedulers())

    /** 正反转数据 */
    fun getReverse(
        carId: String,
        startTime: String,
        endTime: String,
        states: String = "[]",
    ): Single<FwdRev> =
        api.getReverse(carId, startTime, endTime, states)
            .compose(Net.applySingleSchedulers()).map {
                if (it.result == null) {
                    throw Exception(AppContext.getDescById(R.string.desc_toast_no_data_fwd))
                }
                GsonUtil.formObject<FwdRev>(it.result.toString())
            }

    /** 报警处理 */
    fun processAlarm(
        carId: String,
        alarmType: String,
        time: String,
        solveDes: String
    ): Single<HBaseBean> = api.processAlarm(carId, alarmType, time, solveDes)

    //车官家定制
    fun downloadJson(url: String) = noParamApi.downloadJson(url)

    //获取车辆状态详情
    fun getCarState(type: String): Single<ArrayList<CarState>> = api.getCarState(type)
        .compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), CarState::class.java)
        }

    //获取离线状态详情
    fun getOffineState(type: String): Single<ArrayList<OfflineState>> = api.getOffineState(type)
        .compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), OfflineState::class.java)
        }

    //处理报警
    fun handleAlarms(alarms: String, solveDes: String) = api.handleAlarms(alarms, solveDes)
        .compose(Net.applySingleSchedulers())

    //通过区域ID获取区域数据
    fun getRegionById(id: String) = api.getRegionById(id)
        .compose(Net.applySingleSchedulers()).map {
            GsonUtil.formObject<RegionState>(it.result.toString())
        }

    //欠费通知通过车辆
    fun getCharges(carId: String) =
        api.getCharges(carId).compose(Net.applySingleSchedulers())

    //新增车辆收费信息
    fun addCharge(mode: String, charge: String) =
        api.addCharges(charge, mode).compose(Net.applySingleSchedulers())

    //修改车辆收费信息
    fun updateCharge(mode: String, charges: String) =
        api.updateCharges(charges, mode).compose(Net.applySingleSchedulers())

    //删除车辆收费信息
    fun clearCharge(carIds: String) =
        api.clearCharges(carIds).compose(Net.applySingleSchedulers())

    //新增终端
    fun addTmn(
        teamId: String, simCard: String, tmnNo: String,
        tmnKey: String, keyType: String,
        files: List<MultipartBody.Part?>?
    ): Single<TmnManager> =
        noParamApi.addTmn(
            UserConstant.sessionId, teamId, simCard,
            tmnNo, tmnKey, keyType, "", files
        ).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formObject<TmnManager>(it.result.toString())
        }

    //修改终端
    fun updateTmn(
        tmnId: String, teamId: String, simCard: String, tmnNo: String,
        tmnKey: String, keyType: String, deletePics: String,
        files: List<MultipartBody.Part?>?
    ): Single<HBaseBean> =
        noParamApi.updateTmn(
            UserConstant.sessionId, tmnId, teamId, simCard,
            tmnNo, tmnKey, keyType, deletePics, "", files
        ).compose(Net.applySingleSchedulers())

    //查询车队下的终端
    fun getTeamTmn(teamId: String): Single<ArrayList<TmnManager>> =
        api.getTeamTmns(teamId).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), TmnManager::class.java)
        }

    //删除终端
    fun deleteTmn(tmnIds: String): Single<HBaseBean> =
        api.deleteTmn(tmnIds).compose(Net.applySingleSchedulers())


    fun bindTmn(tmnId: String, carId: String) =
        api.bindTmn(tmnId, carId).compose(Net.applySingleSchedulers())

    fun unbindTmn(carId: String) = api.unbindTmn(carId).compose(Net.applySingleSchedulers())

    //获取模糊查询终端
    fun getLickTmn(type: String, value: String) =
        api.getLickTmn(type, value).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), TmnManager::class.java)
        }

    //获取没有绑定车辆的终端信息
    fun getTmnByTeam(teamId: String) = api.getTmnByTeam(teamId)
        .compose(Net.applySingleSchedulers())
        .map {
            GsonUtil.formArrayList(it.result.toString(), TmnManager::class.java)
        }

    //获取没有绑定终端的车辆信息
    fun getCarsByTeam(teamId: String) =
        api.getCarsByTeam(teamId).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), CarTmn::class.java)
        }

    //测试指令Url
    fun testCmdUrl(url: String) = noParamApi.testUrl(url)

    //获取808位置附加状态位字段
    fun getSgnList() = api.getSgnList("gps").compose(Net.applySingleSchedulers()).map {
        GsonUtil.formArrayList(it.result.toString(), LocationInfo::class.java)
    }

    //获取808位置附加状态位字段
    fun covertAlarmMedia(refPath: String) =
        api.covertAlarmMedia(refPath).compose(Net.applySingleSchedulers())

    /**
     * Get data statistic 获取车队统计数据
     *
     * @param teamId
     */
    fun getDataStatistic(teamId: String) =
        api.getDataStatistic(teamId).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formObject<HomeData>(it.result.toString())
        }

    /**
     * 是否可以修改车队
     *
     * @param carId
     */
    fun canChangeTeam(carId: String) =
        api.canChangeTeam(carId).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formObject<ChangeCarTeam>(it.result.toString())
        }

    /**
     * Query cmd logs 司机身份识别结果历史报表 -识别列表
     *
     * @param carId
     * @param startTime
     * @param endTime
     * @param isSuc
     */
    fun queryCmdLogs(carId: String, startTime: String, endTime: String, isSuc: Boolean? = null) =
        api.queryCmdLogs(carId, startTime, endTime, isSuc).compose(Net.applySingleSchedulers())
            .map {
                GsonUtil.formArrayList(it.result.toString(), IdentityInfo::class.java)
            }

    /**
     * 司机身份识别结果历史报表 -识别详情接口
     *
     * @param carId
     * @param gpsTime
     * @param drvFaceImgId
     */
    fun getCompareImgResult(carId: String, gpsTime: String, drvFaceImgId: String) =
        api.getCompareImgResult(carId, gpsTime, drvFaceImgId).compose(Net.applySingleSchedulers())
            .map {
                GsonUtil.formObject<IdentityImg>(it.result.toString())
            }

    /**
     * Get car by team id 通过TeamID获取车辆信息
     *
     * @param teamId
     */
    fun getCarByTeamId(teamId: String) =
        api.getCarByTeamId(teamId).compose(Net.applySingleSchedulers()).map {
            GsonUtil.formArrayList(it.result.toString(), TextCar::class.java)
        }
}